<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>

<body style=" font-family:Arial, Helvetica, sans-serif">
<h1>Update The Final &quot;On Screen &quot; IMEI<br />
</h1>

<form action="" method="post">
<table width="600" border="1" cellspacing="0" cellpadding="10">
  <tr>
    <td colspan="2"><b style="color:red;">Mobile Phone IMEI Number is extreme important to our service.</b><br />
 <span style="font-size:12px;">
 Mobile IMEI is an unique 15 digits number to identify a mobile phone.It is only identity that we can make sure the phone has been serviced by us.<br />
Even the customer returned with all document eg. job confirmed form and invoice,<b> you will still need to check the mobile phone imei to assure the phone is still the one that we fixed for the customer </b>
 </span><br />
 <br />
 <b style="color:red;">If You Need to Input Any 14 digits MEID <span style="font-size:9px;">(Moblie Equipment Identifier)</span>Instead of IMEI <br />
 for Any CDMA Phone. Please Contact Head Office For Help.</b></td>
  </tr>
  <tr>
    <td colspan="2" align="center">Since you have already fixed the device please <b style="color:red;">MUST</b> turn the Mobile on <br />
      and Press *#06# </td>
  </tr>
  <tr>
    <td>The On Device IMEI Is:<br />
    <span style=" font-size:10px;">(You may not change it)</span></td>
    <td>The On Screen IMEI Is<br />
      <span style=" font-size:10px;">(You may only input once)</span></td>
  </tr>
  <tr>
    <td><label for="device_imei"></label>
    <input name="device_imei" type="text" id="device_imei" style="width:200px;" readonly="readonly" <?php 
	if($this->deviceImei == '000000000000000'){
		echo 'value="NO DEVICE IMEI" disabled="disabled" ';
		}
	else{
		echo "value=\"{$this->deviceImei}\"";
		}	
	
	?> /></td>
    <td><input type="text" name="on_screen_imei" id="on_screen_imei" style="width:200px;"
	<?php
    if($this->onscreenImei!=""){
		
		echo "value=\"{$this->onscreenImei}\" disabled=\"disabled\" ";
		}
	?>    
      /></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
 <span id="imei_result">
 	<?php
    if($this->onscreenImei!="" && $_POST){
		
		echo "<h3>IMEI UPDATE SUCCESS!!</3>";
		}
	?>
 
 
 </span>
<br />
<b>you can only input once,please double check before submit,if you made mistake,please contact headoffice Immiediatelly for help.<br /></b>
      <input type="submit" name="btn_submitit" id="btn_submitit"  
      
      	<?php
    if($this->onscreenImei!=""){
		
		echo "value=\"{$this->onscreenImei} Already Submit \" disabled=\"disabled\" ";
		
		}
		else{
		echo 'value="submit final on screen imei"';	
			}
	?>
       />
      <br /></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><span style="font-size:12px;">It is abnormal that these two numbers are not match, but it happens sometime,<br />
We will use &quot;On Screen IMEI&quot; as our main record to identify if the phone been fixed by us.</span></td>
  </tr>
</table>
</form>
</body>
<script language="javascript">
function isIMEI (s) {
var etal = /^[0-9]{15}$/;
  if (!etal.test(s))
    return false;
  if(s.indexOf('11111')>=0)
  	return false;  
  if(s.indexOf('22222')>=0)
  	return false; 
  if(s.indexOf('33333')>=0)
  	return false; 
  if(s.indexOf('44444')>=0)
  	return false;
  if(s.indexOf('55555')>=0)
  	return false; 
  if(s.indexOf('66666')>=0)
  	return false; 
  if(s.indexOf('77777')>=0)
  	return false; 
  if(s.indexOf('88888')>=0)
  	return false; 
  if(s.indexOf('99999')>=0)
  	return false; 
  if(s.indexOf('00000')>=0)
  	return false; 
	
	var str1 = '01234567890';
	var str2 = '09876543210';
	
	for(var i = 0; i < 5; i++){
		var substr = str1.substr(i,5);
		if(s.indexOf(substr)>=0)
		return false;		
	}
	for(var i = 0; i < 5; i++){
		var substr = str2.substr(i,5);
		if(s.indexOf(substr)>=0)
		return false;		
	}
  			
	
  sum = 0; mul = 2; l = 14;
  for (i = 0; i < l; i++) {
    digit = s.substring(l-i-1,l-i);
    tp = parseInt(digit,10)*mul;
    if (tp >= 10)
         sum += (tp % 10) +1;
    else
         sum += tp;
    if (mul == 1)
         mul++;
    else
         mul--;
    }
  chk = ((10 - (sum % 10)) % 10);
  if (chk != parseInt(s.substring(14,15),10))
    return false;
  return true;
}


$("#on_screen_imei").change(function(){
	
		var checkImei = $("#on_screen_imei").val();
		if(isIMEI(checkImei)){
			
			
			$("#imei_result").html("IMEI Check Pass");
			document.getElementById('btn_submitit').removeAttribute("disabled");
			
			} 
		else{
			$("#imei_result").html("You Must Input Validated IMEI!!");
			document.getElementById('btn_submitit').setAttribute("disabled","disabled");
			}		
	});	
	
	




</script>
</html>
